import axios from '../axiosAuth';

export const authApi = {
    login: (data) => {
        return axios.post('/oauth/token', data, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        })
        .then(response => response.data)
        .catch(error => {
            throw new Error(error);
        });
    },
    refreshToken:()=>{
        let refreshToken=localStorage.getItem("refresh_token");
        const formData = new FormData()
        formData.append('grant_type', 'refresh_token');
        formData.append('refresh_token', refreshToken);
        formData.append('client_id', 'wuzzClientId');
        formData.append('client_secret','wuzzSecret');
        return axios.post('/oauth/token',formData,{
             headers: {
                'Content-Type': 'multipart/form-data'
            }
        })
        .then(response => response.data)
        .catch(error => {
            throw new Error(error);
        });
    }
}
